// pages/my/my.js
var app     = getApp();
Page({
  data:{
    userInfo: {},
  },
  onLoad() {
    var that = this;
    wx.getUserInfo({
      success: function(res) {
        console.log(res);
        var userInfo = res.userInfo
        var nickName = userInfo.nickName
        var avatarUrl = userInfo.avatarUrl
        var gender = userInfo.gender //性别 0：未知、1：男、2：女 
        var province = userInfo.province
        var city = userInfo.city
        var country = userInfo.country
        that.setData({
          nickName: nickName,
          avatarUrl:avatarUrl
        })
      }
    })
    // app.getUserInfo( function( userInfo ) {
    //   console.log(userInfo['rawData']);return;
    //   //更新数据
    //    this.setData({
    //       user_info: userInfo,
    //    })
    //   console.log(userInfo);return;
    // })
		// var user_info =  wx.getStorageSync('user_info');
    //    this.setData({
    //       user_info: user_info,
    //    })
	},
  
  orderlist:function(e){
      wx.navigateTo({
        url: '../orderlist/orderlist'
      })
  },

//跳转到订单列表和消息列表
  jump_list:function(e){
      console.log(e);
      var title = e.currentTarget.dataset.title;
      if(title == 1){
        wx.navigateTo({
          url: '../orderlist/orderlist',
        })
      }else{
        wx.navigateTo({
          url: '../message/message',
        })
      }
  },

//修改密码
modify_password:function(){
    wx.navigateTo({
        url: '../modifyPassword/modifyPassword',   
    })
},

//意见反馈
feedback:function(){
    wx.navigateTo({
        url: '../feedback/feedback',   
    })
},

//版本信息
Version:function(){
  wx.navigateTo({
    url: '../version/version',
  })
},

//退出登录
openConfirm:function(){
  wx.showModal({
            title: '提示',
            content: '是否退出登录？？？',
            confirmText: "是",
            cancelText: "否",
            success: function (res) {
                console.log(res);
                if (res.confirm) {
                    wx.clearStorage({
                      key: 'userInfo',
                    })
                    wx.clearStorageSync();
                    wx.redirectTo({
                      url: '../user/user',
                    })
                }else{
                    
                }
            }
        });
  
  
},
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
    
  }
})